﻿namespace MathService.Values
{
    public class MinMaxValue : IResetable
    {
        public double Min { get; set; }
        public double Max { get; set; }

        public Interval Interval { get { return new Interval(Min, Max); } }

        public MinMaxValue()
        {
            Min = double.PositiveInfinity;
            Max = double.NegativeInfinity;
        }

        public MinMaxValue(double minStart, double maxStart)
        {
            Min = minStart;
            Max = maxStart;
        }

        public void AddValue(double x)
        {
            if(x < Min) Min = x;
            if(x > Max) Max = x;
        }

        public void Reset()
        {
            Min = double.PositiveInfinity;
            Max = double.NegativeInfinity;
        }

    }
}

